<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
  public function _initApp()
  {
    // create stream (file or url) writer, passing file as par// ameter
    $writerConfig = array('stream' => '/tmp/logger-test.txt');
    $writer = Zend_Log_Writer_Stream::factory($writerConfig);
    
    // create the priority filter
    $filter = new Zend_Log_Filter_Priority(Zend_Log::EMERG);

    // add the filter
    $writer->addFilter($filter);

    // create logger instance, using factory, passsing writer in parameters
    $logger = Zend_log::factory(array('writer' => $writer));

    // and we're ready to log whatever we need!
    $logger->log('this is just for debugging', Zend_Log::DEBUG);
    $logger->log('this is information', Zend_Log::INFO);
    $logger->log('this is emergency! The most important', Zend_Log::EMERG);
    
    // let's create another writer for this logger
    $newWriter = Zend_Log_Writer_Stream::factory(array('stream' => '/tmp/emergency-log.txt'));
    
    // and new filter
    $newFilter = new Zend_Log_Filter_Priority(Zend_Log::CRIT);
    $newWriter->addFilter($newFilter);
    
    $logger->addWriter($newWriter);


    // set logger in Zend_Registry
    Zend_Registry::set('logger', $logger);
    
    // try logger from the registry
    Zend_Registry::get('logger')->log('we have an emergency!', Zend_Log::EMERG);
  }
}

